#ifndef SCHEDULER_H
#define SCHEDULER_H

class Scheduler;

#include "common.h"
#include "resource.h"

class Scheduler : public CassiopeiaComponent
{
public:
	struct AlertTimeInfo
	{	
		bool Active;
		bool Sound;
		TCHAR SoundFile[MAX_PATH];
		TCHAR Text[MAX_PATH];
		TCHAR Command[MAX_PATH];
		TCHAR CommandArgs[MAX_PATH];
		SYSTEMTIME Time;	
		time_t time_t;
	};

	Scheduler(HINSTANCE hInstance);
	~Scheduler();
	CCState Activate();
	CCState Deactivate();
	void SetAlert();
private:
	void InitSetAlertDialog(HWND hWndDlg);
	void CreateAlert(HWND hWndDlg);
	void CheckAlert();
	void ShowAlertWindow(LPCTSTR text);

	HRESULT ShowOpenFileDialog(HWND hwnd, LPTSTR * fileName, bool waveFiles);
	time_t ConvertSystemTimeToTime_t(SYSTEMTIME systemTime);

	bool dialogOpen;
	HWND hiddenWindow;
	AlertTimeInfo alert;	
	HINSTANCE hInstance;

	static map<HWND, Scheduler*> instances;

	static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
	static VOID CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
	static LRESULT CALLBACK SchedulerAlertWindowWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
	static LRESULT CALLBACK SchedulerHiddenWindowWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);

	
};

#endif